{extend name="public/base"}

{block name="title"}
设置
{/block}

{block name="style"}
{css href="/static/wechat/css/customerservice.css" /}
{/block}

{block name="body"}
<div class="pageControl orderDetails">
    <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;align-items: center;">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">反馈建议</h1>
        <a style="color: #fc4208;" class="send_feedback_form">提交</a>
    </div>

    <!--<textarea name="" rows="" cols="" class="yj_text" placeholder="将您遇到的问题或建议反馈给我们">

    </textarea>-->
    <form action="?" method="post" id="feedback_form">
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <textarea class="weui-textarea js-textarea" placeholder="将您遇到的问题或建议反馈给我们,最多30字" rows="3" name="content"></textarea>
                    <div class="weui-textarea-counter js-tNum"><span>0</span>/30</div>
                </div>
            </div>
        </div>
        <input type="hidden" name="type" value="{$type}">
    </form>
</div>
{/block}

{block name="javascript"}
<script>
    var maxNum=30;
    var reg=/[^/]*$/;
    var number=$('.js-textarea').closest('.weui-cell__bd').find('.js-tNum');
    number.html(number.html().replace(reg,maxNum));
    $('.js-textarea').on('keyup',function(){
        if($(this).val().length>=maxNum){
            var num=$(this).val().substr(0,maxNum);
            $(this).val(num);
        }
        $('.js-textarea').closest('.weui-cell__bd').find('.js-tNum span').html($(this).val().length);
    });

    $(".send_feedback_form").click(function () {
        var _obj = $("#feedback_form");
        $.ajax({
            type : 'post',
            url : _obj.attr('action'),
            data : _obj.serialize(),
            dataType : 'json',
            success : function (msg) {
                if (msg.code == 200) {
                    alert('提交成功！！');
                    window.history.back();
                } else {
                    var code = msg.code;
                    $.alert(error_code[code]);
                }
                console.log(msg);
            }
        });
    });
</script>
{/block}